﻿#region <!-- Using Directives -->

using System;
using System.Windows;
using System.Windows.Forms;

using UserControl = System.Windows.Controls.UserControl;

using Rect = System.Windows.Rect;

#endregion

namespace WordSharpDev
{
	public partial class WordSharpBox<T> : Form where T : UserControl, new()
	{
		public T Child
		{
			get { return (T)WpfContainer.Child; }
		}

		public WordSharpBox()
		{
			InitializeComponent();

			WpfContainer.Child = new T();
		}

		public void Show(Rect p_ParentRect)
		{
			Top = Convert.ToInt32(p_ParentRect.Top + (p_ParentRect.Height - Height) / 2);
			Left = Convert.ToInt32(p_ParentRect.Left + (p_ParentRect.Width - Width) / 2);

			Show();
		}

		public void ShowDialog(Rect p_ParentRect)
		{
			Top = Convert.ToInt32(p_ParentRect.Top + (p_ParentRect.Height - Height) / 2);
			Left = Convert.ToInt32(p_ParentRect.Left + (p_ParentRect.Width - Width) / 2);

			ShowDialog();
		}

		private void WordSharpBox_FormClosing(Object p_Sender, FormClosingEventArgs p_Args)
		{
			p_Args.Cancel = true;

			Hide();
		}
	}
}